<%@ page import="java.awt.*" %>
<%@ page import="javax.imageio.ImageIO" %>
<%@ page import="java.io.File" %>
<%@ page import="java.awt.image.BufferedImage" %>
<%@ page import="com.touzi.utils.QRCodeUtils" %><%--
  Created by IntelliJ IDEA.
  User: w7851
  Date: 2018/5/31
  Time: 12:22
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    response.setContentType("image/jpeg");
    out.clear();
    //这里调整文件路径
    String path=application.getRealPath("/pics/openonbro.jpg");

    Image src= ImageIO.read(new File(path));
    BufferedImage bufferedImage=new BufferedImage(src.getWidth(null),
            src.getHeight(null),BufferedImage.TYPE_INT_RGB);

    Graphics2D g=bufferedImage.createGraphics();
    g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
            RenderingHints.VALUE_INTERPOLATION_BILINEAR);

    g.drawImage(src.getScaledInstance(src.getWidth(null), src.getHeight(null),
            Image.SCALE_SMOOTH), 0, 0,null);

    BufferedImage icon= QRCodeUtils.enCode("https://blog.csdn.net/qq_17085463/article/details/78819577",300,300);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 1));

    // 6、水印图片的位置
    g.drawImage(icon, 10, 10, null);
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER));
    // 7、释放资源
    g.dispose();

    ImageIO.write(bufferedImage,"JPG",response.getOutputStream());
%>